package kolekcje.powtorka;

import java.util.ArrayList;

public class TestGenericsTwo {

	private class Cat extends Animal {
		@SuppressWarnings("unused")
		void meow() {
			System.out.println("meow");
		}
	}

	private class Dog extends Animal {
		@SuppressWarnings("unused")
		void bark() {
			System.out.println("wow wow");
		}
	}

	private abstract class Animal {
		void eat() {
			System.out.println("animal eating");
		}
	}

	public static void main(String[] args) {

		new TestGenericsTwo().go();
	}

	private void go() {
		ArrayList<Animal> animals = new ArrayList<Animal>();
		animals.add(new Dog());
		animals.add(new Cat());
		animals.add(new Dog());
		ArrayList<Dog> dogs = new ArrayList<Dog>();
		dogs.add(new Dog());
		dogs.add(new Dog());
		dogs.add(new Dog());
		takeAnimals(animals);
//		takeAnimals(dogs);
	}

	private void takeAnimals(ArrayList<? extends Animal> animals) {
//	private <T extends Animal> void takeAnimals(ArrayList<T> animals) {
		for (Animal a : animals)
			a.eat();
	}

}
